﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using WCSY.BLL;

public partial class CostsManagement_costsOtherList : System.Web.UI.Page
{
    Fg_deptInfoManager deptM = new Fg_deptInfoManager();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //绑定申请部门
            DataTable deptList = deptM.GetAllList().Tables[0];
            this.ddlApplyDept.DataSource = deptList;
            this.ddlApplyDept.DataTextField = "deptname";
            this.ddlApplyDept.DataValueField = "id";
            this.ddlApplyDept.DataBind();
            gvBind();

        }
    }

    public void gvBind()
    {
        wcsy_costsOtherOrderMstManager mstm = new wcsy_costsOtherOrderMstManager();

        this.GridView1.DataSource = mstm.GetAllListByPara("", "0", "", "", "", "");
        this.GridView1.DataBind();
        if (GridView1.Rows.Count > 0)
        {
            for (int i = 1; i < GridView1.Columns.Count; i++)
            {
                chkLstHead.Items.Add(GridView1.HeaderRow.Cells[i].Text);
                chkLstHead.Items[i - 1].Selected = true;
            }
        }

    }

    protected void btnSure_Click(object sender, EventArgs e)
    {
        for (int i = 0; i < chkLstHead.Items.Count; i++)
        {
            for (int j = 1; i < GridView1.Columns.Count; j++)
            {
                if (chkLstHead.Items[i].Selected == true && chkLstHead.Items[i].Text == GridView1.Columns[j].HeaderText)
                {
                    GridView1.Columns[j].Visible = true;
                    break;
                }
                if (chkLstHead.Items[i].Selected == false && chkLstHead.Items[i].Text == GridView1.Columns[j].HeaderText)
                {
                    GridView1.Columns[j].Visible = false;
                    break;
                }
            }
        }
    }

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Attributes.Add("onmouseover", "if(this!=prevselitem){this.style.backgroundColor='#Efefef'}");//当鼠标停留时更改背景色
            e.Row.Attributes.Add("onmouseout", "if(this!=prevselitem){this.style.backgroundColor='#ffffff'}");//当鼠标移开时还原背景色
            e.Row.Attributes.Add("onclick", "this.cells[0].childNodes[0].click();");//selectx(this);this.cells[1].childNodes[0].click();
            e.Row.Attributes.Add("ondblclick", "rowdblClick(" + e.Row.Cells[2].Text + ")");

        }
    }
    //条件查询
    protected void btnSec_Click(object sender, EventArgs e)
    {
        wcsy_costsOtherOrderMstManager mstm = new wcsy_costsOtherOrderMstManager();
        string sysno = txtSysno.Text;
        string dept = ddlApplyDept.SelectedValue;
        string applypsn = txtApplyPsn.Text;
        string fillpsn = txtFillPsn.Text;
        string filldateB = txtFilldateB.Text;
        string filldateE = txtFilldateE.Text;
        this.GridView1.DataSource = mstm.GetAllListByPara(sysno, dept, applypsn, fillpsn, filldateB, filldateE);
        this.GridView1.DataBind();
    }
}
